
package com.ag.lwc.action;

import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.apache.struts2.interceptor.SessionAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;


import com.ag.bean.TbDept;
import com.ag.bean.TbEvent;
import com.ag.bean.TbUser;
import com.ag.common.AjaxNotify;
import com.ag.common.BaseAction;
import com.ag.common.DateUtil;
import com.ag.common.EventUtil;
import com.ag.common.KeyUtil;
import com.ag.wzp.service.impl.EventServiceImpl;

/**
 * @author 刘万才
 * 事件善后
 * 
 */
@Scope("prototype")
@Controller("eventAfterAction")
public class EventAfterAction extends BaseAction implements SessionAware {

	private static final long serialVersionUID = 1L;
	private static final Logger logger = Logger.getLogger(EventAfterAction.class);
	
	@Resource(name="eventServiceImpl")
	private EventServiceImpl eventServiceImpl;
	private TbEvent event = new TbEvent();
	private List<TbEvent> events;
	private List<TbDept> depts;
	//private String selDept;//报送中选择的部门ID
	private String submitTime;//报送时间
	//private String elId;//事件等级ID
	String ajaxRst;
	private String EId;//事件ID
	private String daContent;//处置建议内容
	private Map<String, Object> sessionMap;
	@Override
	public void setSession(Map<String, Object> session) {
		this.sessionMap = session;
	}
	/**
	 * 保存事件
	 * @return
	 */
	public String save(){
		logger.info("eventTime = "+event.getEEventtime()+"---");
		logger.info("event = "+event.getESubmitTime()+"---");
		eventServiceImpl.save(event);
		ajaxRst = AjaxNotify.SUCCESS;
		return "eventSave";
		
	}
	/**
	 * 根据EId获取Event，用于查看事件详情
	 * @return
	 */
	public String findById(){
		System.out.println("进到万才的事件善后的action了");
		logger.info("do get !"+ event.getEId());
		String eid = event.getEId();
		if(eid!=null&&eid.length()>0){
			//事件处理过程中需要session里有EId
			this.sessionMap.put(EventUtil.PROCESSING_EVENT_ID, eid);
			event=eventServiceImpl.findById(eid);
			return "findByEID";
		}else{
			return ERROR;
		}
	}
	/**
	 * 临时方法
	 * 根据EId获取Event，用于查看事件详情
	 * @return
	 */
	public String getById(){
		logger.info("do get !"+ event.getEId());
		String eid = event.getEId();
		if(eid!=null&&eid.length()>0){
			//事件处理过程中需要session里有EId
			this.sessionMap.put(EventUtil.PROCESSING_EVENT_ID, eid);
			event=eventServiceImpl.findById(eid);
			return "getByEID";
		}else{
			return ERROR;
		}
	}

	public TbEvent getEvent() {
		return event;
	}
	public void setEvent(TbEvent event) {
		this.event = event;
	}
	public List<TbEvent> getEvents() {
		return events;
	}
	public void setEvents(List<TbEvent> events) {
		this.events = events;
	}
	public List<TbDept> getDepts() {
		return depts;
	}
	public void setDepts(List<TbDept> depts) {
		this.depts = depts;
	}
	public String getSubmitTime() {
		return submitTime;
	}
	public void setSubmitTime(String submitTime) {
		this.submitTime = submitTime;
	}
	public String getEId() {
		return EId;
	}
	public void setEId(String eId) {
		EId = eId;
	}
	public String getDaContent() {
		return daContent;
	}
	public void setDaContent(String daContent) {
		this.daContent = daContent;
	}
	public String getAjaxRst() {
		return ajaxRst;
	}
	public void setAjaxRst(String ajaxRst) {
		this.ajaxRst = ajaxRst;
	}
	

}

